Skip to content

Allow nested cookie values in the CookieProvider type - #21

Merged
koriym merged 1 commit into
1.xfrom
cookie-provider-nested-type
Nov 23, 2026
Merged

koriym merged 1 commit into
1.xfrom
cookie-provider-nested-type

Conversation

@koriym

@koriym koriym commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #15 (CodeRabbit comment #15 (comment)).

PHP parses cookie names with brackets into nested arrays: Cookie: cookie[foo]=bar; cookie[x][y]=z gives $_COOKIE['cookie'] = ['foo' => 'bar', 'x' => ['y' => 'z']] (checked with php -S and curl), and SessionFactory::newInstance() accepts that array.

  • Change the CookieProvider template type from array<array-key, string> to array<array-key, string|array<array-key, mixed>>, the same shape Psalm uses for $_GET/$_POST.
  • With the old type Psalm 7 called a needed is_array() guard on a cookie value a DocblockTypeContradiction and let a possibly-array value reach strlen(); with the new type it reports PossiblyInvalidArgument there.
  • SessionProvider stays ProviderInterface<Session>; newInstance() returns Session.

Summary by CodeRabbit

  • Refactor
    • Updated the provider’s type declarations to reflect that cookie values may be strings or arrays of mixed values. This improves the accuracy of type information for developers and tools; it does not describe a change to cookie behavior.

PHP parses cookie names with brackets, such as cookie[foo]=bar, into nested arrays, so $_COOKIE values are strings or arrays.
@koriym

koriym commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (092ccdb) to head (90aac6e).

Additional details and impacted files
@@             Coverage Diff             @@
##                 1.x       #21   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity         5         5           
===========================================
  Files              5         5           
  Lines             24        24           
===========================================
  Hits              24        24           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CookieProvider implementation annotation now permits cookie values to be strings or arrays of mixed values.

Changes: Cookie provider

Layer / File(s) Summary
Cookie provider value type
src/CookieProvider.php
The ProviderInterface generic annotation now allows strings or arrays of mixed values.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Change: Other

Merge Risk: Minimal · up to 90aac

This change updates a type annotation so that cookie values can be nested arrays, matching how PHP parses bracketed cookie names. Runtime behavior does not change, and the risk of merging is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: the CookieProvider type now allows nested cookie values. The raw summary confirms the generic type changed from string values to string|array values in src/CookieProv…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: the CookieProvider type now allows nested cookie values. The raw summary confirms the generic type changed from string values to string|array values in src/CookieProvider.php, and the objectives say PHP parses bracketed cookie names into nested arrays. The title is specific and matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6b7a9f88-0717-43ec-9980-4dac5d4fa704
Commits

Reviewing files that changed from the base of the PR and between 092ccdb and 90aac6e.

Files selected for processing: 1

  • src/CookieProvider.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@koriym
koriym merged commit 3546cc1 into 1.x Nov 23, 2026
35 of 36 checks passed
@koriym
koriym deleted the cookie-provider-nested-type branch November 23, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant